<template>

    <div style="width: 100%;height: 100%;">
        
        <img :src="img" style="width: 100%;"/>
      
    </div>




</template>

<script>
	
	import { Swiper, GroupTitle, SwiperItem, XButton, Divider ,base64} from 'vux'

export default {
	
	components: {
		    Swiper,
		    SwiperItem,
		    GroupTitle,
		    XButton,
		    Divider,
		    base64
		},
		
	data (){
		return{
			
			access_token:'',
			img:''
			
		}
	},
		
	methods:{
		
		//收藏
	    getDetail(){
	    	
	    	this.$store.commit('updateLoadingStatus',true);
	    	
	    	this.$http.post(this.$store.state.api + 'userlogin/qrcode',
	    	{
	    		access_token:this.access_token
	    	})
	    	.then((response) => {
	    		
	    		console.log(response)
			
			if(response.body.code == 0) {
				
				this.img = response.body.data
				console.log(this.img)
				
			} else {
				
			}
			
			this.$store.commit('updateLoadingStatus',false);
				
			
			}, (response) => {
                 
                 
			});
	    },
	    
	    //获取地址栏信息
		getUrlStr(name){
			
	      let reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)","i");
	      if(reg.test(window.location.href)){
	        return unescape(RegExp.$2.replace(/\+/g," "))
	      }
	      return undefined
	    },
		
	},
	
	mounted(){
		
		var access_token = this.getUrlStr('access_token');
        var parentId = this.getUrlStr('parent_id');
           
        if(parentId == undefined){
          parentId = 0;
        }
           
        var uid = this.getUrlStr('uid');
       
        console.log(parentId.toString().indexOf('?'));
       
        if(parentId.toString().indexOf('?') > 0){
       	    parentId = parentId.split('?')[0];
        }
       
       
        var locurl = location.href;
        locurl = base64.encode(locurl.split('?')[0]);        
      
      
   
        if(access_token != undefined){
     
           localStorage.setItem("access_token",access_token); 
           localStorage.setItem("parent_id",this.getUrlStr('uid'));


        }
           
        console.log('-3-'+localStorage.getItem('access_token'));
           
        if(localStorage.getItem('access_token') != null){
         
        this.$root.registerjudge();
        this.$root.getShare();
              
        }else{
            	
           console.log(222);
        this.$root.gotoWechat(locurl,parentId);
        }
           
       
         
    	this.access_token = localStorage.getItem('access_token');
		
		this.getDetail();
		
	}
		
		
		
	}


</script>

<style>
	
</style>